/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JCCFlux.java
 * procedure complete.
 * condition -layoutComplete.
 * pending for cleanup and tuning
 * flowchart, process ui complete T_T full of bugs T_T
 * 
 * Created on Dec 3, 2011, 3:20:43 PM
 */
package jccflux;


import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.util.*;
import java.awt.event.*;
import java.lang.Math;
import java.awt.FontMetrics;
import java.awt.geom.Line2D;

/**
 *
 * @author MrYoso
 */
public class JCCFlux extends javax.swing.JFrame implements ActionListener,MouseListener {

    /** Creates new form JCCFlux */
    flowchart_panel canvas = new flowchart_panel();
    public JCCFlux() {
        initComponents();
        //-------main program settings---------//
        setExtendedState(JFrame.MAXIMIZED_BOTH);
        setTitle("JCCFlux- Flowchart to Code Converter");
        //setMinimumSize(new Dimension(900, 600));
        //------//main program settings//-----//
        initializeFlowchartElements();
        flowchart_panel_container.add(canvas);
        canvas.setVisible(false);
        
        hideAllMainButtons();
        btn_add.setVisible(true);
        
    }
    public void hideAllMainButtons()
    {
        btn_add.setVisible(false);
        btn_edit.setVisible(false);
        btn_delete.setVisible(false);
        btn_insert.setVisible(false);        
    }
    public void load_ui_conditionLayout()
    {
        panel_properties.removeAll();
        panel_properties.add(panel_layout_condition_container,BorderLayout.CENTER); 
        
        cmb_condition_firstElement.removeAllItems();
        fill_combobox_content(cmb_condition_firstElement,"all");
        
        cmb_condition_logicalOperator.removeAllItems();
        cmb_condition_logicalOperator.addItem(">");
        cmb_condition_logicalOperator.addItem("<");
        cmb_condition_logicalOperator.addItem("=");
        cmb_condition_logicalOperator.addItem(">=");
        cmb_condition_logicalOperator.addItem("<=");
        
        panel_properties.add(panel_addEditDelete,BorderLayout.SOUTH);

        hideAllMainButtons();
        btn_add.setVisible(true);
        
        //lbl_status.setText("gagagag");
    }
    public void load_ui_processLayout(String mode)
    {
        panel_properties.removeAll();
        panel_properties.add(panel_layout_process,BorderLayout.NORTH);
        cmb_procedure.setSelectedItem(mode);
        
        panel_properties.remove(panel_layout_initialization);
        panel_properties.remove(panel_layout_arithmetic);
        panel_properties.remove(panel_layout_set_header);
        panel_properties.remove(panel_layout_custom);
        
        panel_layout_initialization.setVisible(false);
        panel_layout_arithmetic.setVisible(false);
        panel_layout_set_header.setVisible(false);
        panel_layout_custom.setVisible(false);
        
        if(mode.equals("initialization"))
        {
            panel_properties.add(panel_layout_initialization,BorderLayout.CENTER);
            
            txt_init_value.setText("");
            txt_init_variable.setText("");
            cmb_init_dataType.removeAllItems();
            cmb_init_dataType.addItem("numeric");
            cmb_init_dataType.addItem("string");
            cmb_init_dataType.addItem("char");
            cmb_init_dataType.addItem("flag");
            txt_init_variable.grabFocus();
            
            panel_layout_initialization.setVisible(true);
        }
        else
        if(mode.equals("arithmetic"))
        {
            panel_properties.add(panel_layout_arithmetic,BorderLayout.CENTER);
            
            cmb_arith_variable.removeAllItems();
            fill_combobox_content(cmb_arith_variable,"numeric");
            txt_arith_value.setText("");
            cmb_arith_variable.grabFocus();            
            
            panel_layout_arithmetic.setVisible(true);
        }
        else 
        if(mode.equals("set"))
        {
            panel_properties.add(panel_layout_set_header,BorderLayout.CENTER);
            
            cmb_set_variableList.removeAllItems();
            cmb_set_str_variableList.removeAllItems();
            fill_combobox_content(cmb_set_variableList,"all");
            
            panel_layout_set_header.setVisible(true);
            
        }
        else 
        if(mode.equals("custom"))
        {
            panel_properties.add(panel_layout_custom,BorderLayout.CENTER);            
            txtA_custom_input.setText("");                        
            panel_layout_custom.setVisible(true);            
        }


        panel_properties.add(panel_addEditDelete,BorderLayout.SOUTH);
        
        hideAllMainButtons();
        btn_add.setVisible(true);
        
    }
    public void mouseExited(MouseEvent e) 
    {}
    public void mouseEntered(MouseEvent e)
    {
        for(int i=0;i<1000;i++)
        {
            if(e.getSource()==btn_symbol[i])
            {
               jTextArea2.setText(btn_symbol[i].getText());
            }
        }
    }
    public void mouseClicked(MouseEvent e)
    {}
    public void mousePressed(MouseEvent e)
    {}
    public void mouseReleased(MouseEvent e) 
    {}
    
    public void actionPerformed(ActionEvent MrYoSo)
    {
        lbl_flowState.setText("normal");
        lbl_motherIndexHolder.setText("");
        for(int i=0;i<1000;i++)
        {
            btn_trueRoute[i].setEnabled(true);
            btn_falseRoute[i].setEnabled(true);
        }
        for(int i=0;i<1000;i++)
        {
           if(MrYoSo.getSource()==btn_trueRoute[i])
           {
               lbl_flowState.setText("true");
               lbl_motherIndexHolder.setText(""+getMotherCode(i));
               btn_trueRoute[i].setEnabled(false);
           }
           if(MrYoSo.getSource()==btn_falseRoute[i])
           {
               lbl_flowState.setText("false");
               lbl_motherIndexHolder.setText(""+getMotherCode(i));
               btn_falseRoute[i].setEnabled(false);
           }
        }
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panel_layout_process = new javax.swing.JPanel();
        panel_processLayout_header = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        cmb_procedure = new javax.swing.JComboBox();
        lbl_properties = new javax.swing.JLabel();
        panel_addEditDelete = new javax.swing.JPanel();
        btn_add = new javax.swing.JButton();
        btn_edit = new javax.swing.JButton();
        btn_delete = new javax.swing.JButton();
        btn_insert = new javax.swing.JButton();
        panel_layout_initialization = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        cmb_init_dataType = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        txt_init_variable = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        txt_init_value = new javax.swing.JTextField();
        panel_layout_arithmetic = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        cmb_arith_variable = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        txt_arith_value = new javax.swing.JTextField();
        cmb_init_flag = new javax.swing.JComboBox();
        panel_layout_set_header = new javax.swing.JPanel();
        panel_layout_set_header_container = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        cmb_set_variableList = new javax.swing.JComboBox();
        panel_layout_set_detail_str = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtA_setLayout_str_Value = new javax.swing.JTextArea();
        jPanel2 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        txt_set_str_variableList = new javax.swing.JTextField();
        btn_setLayout_str_deleteVariable = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        cmb_set_str_variableList = new javax.swing.JComboBox();
        filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(2, 0), new java.awt.Dimension(2, 0), new java.awt.Dimension(2, 32767));
        jPanel7 = new javax.swing.JPanel();
        btn_setLayout_str_append = new javax.swing.JButton();
        btn_setLayout_str_clear = new javax.swing.JButton();
        panel_layout_set_detail_num = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        txt_setLayout_value = new javax.swing.JTextField();
        panel_layout_set_detail_flag = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        cmb_setLayout_value = new javax.swing.JComboBox();
        panel_layout_set_detail_char = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        txt_setLayout_value_char = new javax.swing.JTextField();
        DUMMY_lbl_set_dataTypeContainer = new javax.swing.JLabel();
        panel_layout_custom = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        txtA_custom_input = new javax.swing.JTextArea();
        panel_layout_condition_container = new javax.swing.JPanel();
        panel_layout_condition = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        cmb_condition_firstElement = new javax.swing.JComboBox();
        jLabel13 = new javax.swing.JLabel();
        cmb_condition_secondElement = new javax.swing.JComboBox();
        jPanel8 = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        cmb_condition_logicalOperator = new javax.swing.JComboBox();
        lbl_properties1 = new javax.swing.JLabel();
        btn_teminal_start = new javax.swing.JButton();
        panel_north_toolBar = new javax.swing.JPanel();
        jLabel15 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        lbl_flowState = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        lbl_motherContainer = new javax.swing.JLabel();
        lbl_motherIndexHolder = new javax.swing.JLabel();
        panel_south_etc = new javax.swing.JPanel();
        lbl_status = new javax.swing.JLabel();
        scroll_left_mainTools = new javax.swing.JScrollPane();
        panel_left_mainTools = new javax.swing.JPanel();
        panel_mainButtons = new javax.swing.JPanel();
        btn_main_process = new javax.swing.JButton();
        btn_main_io = new javax.swing.JButton();
        btn_main_conditon = new javax.swing.JButton();
        btn_main_loops = new javax.swing.JButton();
        panel_properties_container = new javax.swing.JPanel();
        panel_properties = new javax.swing.JPanel();
        scrollP_flowchartDisplay = new javax.swing.JScrollPane();
        flowchart_panel_container = new javax.swing.JPanel();
        jButton3 = new javax.swing.JButton();
        jPanel9 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTextArea2 = new javax.swing.JTextArea();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        panel_layout_process.setBackground(new java.awt.Color(153, 255, 204));
        panel_layout_process.setLayout(new java.awt.BorderLayout());

        panel_processLayout_header.setBackground(new java.awt.Color(255, 255, 204));
        panel_processLayout_header.setLayout(new java.awt.GridLayout(1, 2, 5, 5));

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Procedure");
        panel_processLayout_header.add(jLabel1);

        cmb_procedure.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "initialization", "arithmetic", "set", "custom" }));
        cmb_procedure.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmb_procedureActionPerformed(evt);
            }
        });
        panel_processLayout_header.add(cmb_procedure);

        panel_layout_process.add(panel_processLayout_header, java.awt.BorderLayout.CENTER);

        lbl_properties.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbl_properties.setText("Properties");
        lbl_properties.setMinimumSize(new java.awt.Dimension(49, 20));
        lbl_properties.setPreferredSize(new java.awt.Dimension(49, 30));
        panel_layout_process.add(lbl_properties, java.awt.BorderLayout.PAGE_START);

        panel_addEditDelete.setBackground(new java.awt.Color(204, 204, 255));
        panel_addEditDelete.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.TRAILING));

        btn_add.setText("Add");
        btn_add.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_addActionPerformed(evt);
            }
        });
        panel_addEditDelete.add(btn_add);

        btn_edit.setText("Edit");
        panel_addEditDelete.add(btn_edit);

        btn_delete.setText("Delete");
        panel_addEditDelete.add(btn_delete);

        btn_insert.setText("Insert");
        btn_insert.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_insertActionPerformed(evt);
            }
        });
        panel_addEditDelete.add(btn_insert);

        panel_layout_initialization.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 1, 1, 1));
        panel_layout_initialization.setLayout(new java.awt.GridLayout(3, 2, 5, 5));

        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("Data Type");
        panel_layout_initialization.add(jLabel2);

        cmb_init_dataType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "numeric", "string", "char", "flag" }));
        cmb_init_dataType.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmb_init_dataTypeActionPerformed(evt);
            }
        });
        panel_layout_initialization.add(cmb_init_dataType);

        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText("Variable");
        panel_layout_initialization.add(jLabel3);
        panel_layout_initialization.add(txt_init_variable);

        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel4.setText("Value");
        panel_layout_initialization.add(jLabel4);

        txt_init_value.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txt_init_valueActionPerformed(evt);
            }
        });
        panel_layout_initialization.add(txt_init_value);

        panel_layout_arithmetic.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 1, 1, 1));
        panel_layout_arithmetic.setLayout(new java.awt.GridLayout(2, 2, 5, 5));

        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel6.setText("Variable");
        panel_layout_arithmetic.add(jLabel6);

        cmb_arith_variable.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        panel_layout_arithmetic.add(cmb_arith_variable);

        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel7.setText("Value");
        panel_layout_arithmetic.add(jLabel7);

        txt_arith_value.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                txt_arith_valueMouseClicked(evt);
            }
        });
        txt_arith_value.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txt_arith_valueFocusGained(evt);
            }
        });
        panel_layout_arithmetic.add(txt_arith_value);

        cmb_init_flag.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "true", "false" }));

        panel_layout_set_header.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 1, 5, 1));
        panel_layout_set_header.setLayout(new java.awt.BorderLayout());

        panel_layout_set_header_container.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 5, 1));
        panel_layout_set_header_container.setLayout(new java.awt.GridLayout(1, 2, 5, 5));

        jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel5.setText("Variable");
        panel_layout_set_header_container.add(jLabel5);

        cmb_set_variableList.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmb_set_variableList.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmb_set_variableListActionPerformed(evt);
            }
        });
        panel_layout_set_header_container.add(cmb_set_variableList);

        panel_layout_set_header.add(panel_layout_set_header_container, java.awt.BorderLayout.PAGE_START);

        panel_layout_set_detail_str.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        panel_layout_set_detail_str.setLayout(new java.awt.BorderLayout());

        jScrollPane1.setBorder(null);
        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        txtA_setLayout_str_Value.setColumns(15);
        txtA_setLayout_str_Value.setLineWrap(true);
        txtA_setLayout_str_Value.setRows(5);
        txtA_setLayout_str_Value.setWrapStyleWord(true);
        jScrollPane1.setViewportView(txtA_setLayout_str_Value);

        panel_layout_set_detail_str.add(jScrollPane1, java.awt.BorderLayout.CENTER);

        jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.LINE_AXIS));

        jPanel4.setLayout(new java.awt.BorderLayout());

        jPanel3.setBackground(new java.awt.Color(255, 255, 204));
        jPanel3.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 2, 1));
        jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.LINE_AXIS));

        txt_set_str_variableList.setEditable(false);
        txt_set_str_variableList.setBorder(null);
        txt_set_str_variableList.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txt_set_str_variableListActionPerformed(evt);
            }
        });
        jPanel3.add(txt_set_str_variableList);

        btn_setLayout_str_deleteVariable.setText("D");
        btn_setLayout_str_deleteVariable.setMargin(new java.awt.Insets(0, 0, 0, 0));
        btn_setLayout_str_deleteVariable.setMaximumSize(new java.awt.Dimension(17, 17));
        btn_setLayout_str_deleteVariable.setMinimumSize(new java.awt.Dimension(17, 17));
        btn_setLayout_str_deleteVariable.setPreferredSize(new java.awt.Dimension(17, 17));
        btn_setLayout_str_deleteVariable.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_setLayout_str_deleteVariableActionPerformed(evt);
            }
        });
        jPanel3.add(btn_setLayout_str_deleteVariable);

        jPanel4.add(jPanel3, java.awt.BorderLayout.PAGE_START);

        jPanel5.setBackground(new java.awt.Color(204, 255, 204));
        jPanel5.setLayout(new javax.swing.BoxLayout(jPanel5, javax.swing.BoxLayout.LINE_AXIS));

        jPanel6.setLayout(new javax.swing.BoxLayout(jPanel6, javax.swing.BoxLayout.LINE_AXIS));

        cmb_set_str_variableList.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jPanel6.add(cmb_set_str_variableList);
        jPanel6.add(filler1);

        jPanel5.add(jPanel6);

        jPanel7.setLayout(new java.awt.GridLayout(1, 2, 2, 0));

        btn_setLayout_str_append.setText("+");
        btn_setLayout_str_append.setToolTipText("Append Variable");
        btn_setLayout_str_append.setMargin(new java.awt.Insets(0, 0, 0, 0));
        btn_setLayout_str_append.setMaximumSize(new java.awt.Dimension(23, 23));
        btn_setLayout_str_append.setMinimumSize(new java.awt.Dimension(23, 23));
        btn_setLayout_str_append.setPreferredSize(new java.awt.Dimension(22, 22));
        btn_setLayout_str_append.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_setLayout_str_appendActionPerformed(evt);
            }
        });
        jPanel7.add(btn_setLayout_str_append);

        btn_setLayout_str_clear.setText("C");
        btn_setLayout_str_clear.setToolTipText("Clear");
        btn_setLayout_str_clear.setMargin(new java.awt.Insets(0, 0, 0, 0));
        btn_setLayout_str_clear.setMaximumSize(new java.awt.Dimension(23, 23));
        btn_setLayout_str_clear.setMinimumSize(new java.awt.Dimension(23, 23));
        btn_setLayout_str_clear.setPreferredSize(new java.awt.Dimension(22, 22));
        btn_setLayout_str_clear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_setLayout_str_clearActionPerformed(evt);
            }
        });
        jPanel7.add(btn_setLayout_str_clear);

        jPanel5.add(jPanel7);

        jPanel4.add(jPanel5, java.awt.BorderLayout.PAGE_END);

        jPanel2.add(jPanel4);

        panel_layout_set_detail_str.add(jPanel2, java.awt.BorderLayout.PAGE_END);

        panel_layout_set_detail_num.setLayout(new java.awt.GridLayout(1, 0));

        jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel8.setText("Value ");
        panel_layout_set_detail_num.add(jLabel8);
        panel_layout_set_detail_num.add(txt_setLayout_value);

        panel_layout_set_detail_flag.setLayout(new java.awt.GridLayout(1, 0));

        jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel9.setText("Value");
        panel_layout_set_detail_flag.add(jLabel9);

        cmb_setLayout_value.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        panel_layout_set_detail_flag.add(cmb_setLayout_value);

        panel_layout_set_detail_char.setLayout(new java.awt.GridLayout(1, 0));

        jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel10.setText("Value ");
        panel_layout_set_detail_char.add(jLabel10);
        panel_layout_set_detail_char.add(txt_setLayout_value_char);

        DUMMY_lbl_set_dataTypeContainer.setText("jLabel10");

        panel_layout_custom.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 0, 0, 0));
        panel_layout_custom.setLayout(new java.awt.BorderLayout());

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel12.setForeground(new java.awt.Color(153, 153, 153));
        jLabel12.setText("<html> *contents in this textbox<br/>      wil not be traslated into code.</html>");
        panel_layout_custom.add(jLabel12, java.awt.BorderLayout.PAGE_END);

        jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        txtA_custom_input.setColumns(15);
        txtA_custom_input.setRows(5);
        jScrollPane2.setViewportView(txtA_custom_input);

        panel_layout_custom.add(jScrollPane2, java.awt.BorderLayout.CENTER);

        panel_layout_condition_container.setLayout(new java.awt.BorderLayout());

        panel_layout_condition.setLayout(new java.awt.BorderLayout());

        jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jPanel1.setLayout(new java.awt.GridLayout(2, 2, 5, 5));

        jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel11.setText("First Element");
        jPanel1.add(jLabel11);

        cmb_condition_firstElement.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmb_condition_firstElement.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmb_condition_firstElementActionPerformed(evt);
            }
        });
        jPanel1.add(cmb_condition_firstElement);

        jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel13.setText("Second Element");
        jPanel1.add(jLabel13);

        cmb_condition_secondElement.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmb_condition_secondElement.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmb_condition_secondElementActionPerformed(evt);
            }
        });
        jPanel1.add(cmb_condition_secondElement);

        panel_layout_condition.add(jPanel1, java.awt.BorderLayout.PAGE_START);

        jPanel8.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 0, 5, 0));
        jPanel8.setLayout(new java.awt.GridLayout(1, 2, 5, 0));

        jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel14.setText("Logical Operator");
        jPanel8.add(jLabel14);

        cmb_condition_logicalOperator.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jPanel8.add(cmb_condition_logicalOperator);

        panel_layout_condition.add(jPanel8, java.awt.BorderLayout.PAGE_END);

        panel_layout_condition_container.add(panel_layout_condition, java.awt.BorderLayout.CENTER);

        lbl_properties1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbl_properties1.setText("Properties");
        lbl_properties1.setMinimumSize(new java.awt.Dimension(49, 20));
        lbl_properties1.setPreferredSize(new java.awt.Dimension(49, 30));
        panel_layout_condition_container.add(lbl_properties1, java.awt.BorderLayout.PAGE_START);

        btn_teminal_start.setText("Start");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(800, 600));

        panel_north_toolBar.setBackground(new java.awt.Color(227, 227, 227));
        panel_north_toolBar.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEADING, 2, 1));
        panel_north_toolBar.add(jLabel15);

        jButton1.setText("New");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        panel_north_toolBar.add(jButton1);

        lbl_flowState.setText("normal");
        panel_north_toolBar.add(lbl_flowState);

        jButton2.setText("jButton2");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        panel_north_toolBar.add(jButton2);
        panel_north_toolBar.add(lbl_motherContainer);
        panel_north_toolBar.add(lbl_motherIndexHolder);

        getContentPane().add(panel_north_toolBar, java.awt.BorderLayout.PAGE_START);

        panel_south_etc.setBackground(new java.awt.Color(255, 204, 204));
        panel_south_etc.setLayout(new java.awt.BorderLayout());

        lbl_status.setText("STATUS");
        panel_south_etc.add(lbl_status, java.awt.BorderLayout.PAGE_END);

        getContentPane().add(panel_south_etc, java.awt.BorderLayout.PAGE_END);

        scroll_left_mainTools.setBorder(null);
        scroll_left_mainTools.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        scroll_left_mainTools.setViewportBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));

        panel_left_mainTools.setBackground(new java.awt.Color(255, 255, 204));
        panel_left_mainTools.setLayout(new javax.swing.BoxLayout(panel_left_mainTools, javax.swing.BoxLayout.PAGE_AXIS));

        panel_mainButtons.setBackground(new java.awt.Color(255, 204, 204));
        panel_mainButtons.setLayout(new java.awt.GridLayout(2, 2, 5, 5));

        btn_main_process.setText("Process");
        btn_main_process.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_main_processActionPerformed(evt);
            }
        });
        panel_mainButtons.add(btn_main_process);

        btn_main_io.setText("Input/Output");
        panel_mainButtons.add(btn_main_io);

        btn_main_conditon.setText("Condition");
        btn_main_conditon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_main_conditonActionPerformed(evt);
            }
        });
        panel_mainButtons.add(btn_main_conditon);

        btn_main_loops.setText("Loop");
        panel_mainButtons.add(btn_main_loops);

        panel_left_mainTools.add(panel_mainButtons);

        panel_properties_container.setBackground(new java.awt.Color(204, 255, 204));
        panel_properties_container.setLayout(new java.awt.BorderLayout());

        panel_properties.setLayout(new javax.swing.BoxLayout(panel_properties, javax.swing.BoxLayout.PAGE_AXIS));
        panel_properties_container.add(panel_properties, java.awt.BorderLayout.PAGE_START);

        panel_left_mainTools.add(panel_properties_container);

        scroll_left_mainTools.setViewportView(panel_left_mainTools);

        getContentPane().add(scroll_left_mainTools, java.awt.BorderLayout.LINE_START);

        scrollP_flowchartDisplay.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        scrollP_flowchartDisplay.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        scrollP_flowchartDisplay.setAutoscrolls(true);

        flowchart_panel_container.setAutoscrolls(true);

        jButton3.setText("jButton3");
        jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jButton3MouseEntered(evt);
            }
        });
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        flowchart_panel_container.add(jButton3);

        scrollP_flowchartDisplay.setViewportView(flowchart_panel_container);

        getContentPane().add(scrollP_flowchartDisplay, java.awt.BorderLayout.CENTER);

        jPanel9.setLayout(new javax.swing.BoxLayout(jPanel9, javax.swing.BoxLayout.PAGE_AXIS));

        jTextArea1.setColumns(20);
        jTextArea1.setRows(18);
        jScrollPane3.setViewportView(jTextArea1);

        jPanel9.add(jScrollPane3);

        jTextArea2.setColumns(20);
        jTextArea2.setRows(1);
        jScrollPane4.setViewportView(jTextArea2);

        jPanel9.add(jScrollPane4);

        getContentPane().add(jPanel9, java.awt.BorderLayout.LINE_END);

        jMenu1.setText("File");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btn_main_processActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_main_processActionPerformed
        // TODO add your handling code here:
        load_ui_processLayout("initialization");
        current_mode = "process";
        btn_add.setVisible(true);
    }//GEN-LAST:event_btn_main_processActionPerformed

    private void txt_init_valueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txt_init_valueActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txt_init_valueActionPerformed

    private void cmb_procedureActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmb_procedureActionPerformed
        // TODO add your handling code here:
        if(cmb_procedure.getSelectedItem().equals("initialization"))
            load_ui_processLayout("initialization");
        else
        if(cmb_procedure.getSelectedItem().equals("arithmetic"))
            load_ui_processLayout("arithmetic");
        else
        if(cmb_procedure.getSelectedItem().equals("set"))
            load_ui_processLayout("set");
        else
        if(cmb_procedure.getSelectedItem().equals("custom"))
            load_ui_processLayout("custom");
    }//GEN-LAST:event_cmb_procedureActionPerformed

    private void btn_addActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_addActionPerformed
        // TODO add your handling code here:
        addObjectToLinkedList();
        clearAllTextBoxes();
        displayToCanvas();
    }//GEN-LAST:event_btn_addActionPerformed

    private void cmb_init_dataTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmb_init_dataTypeActionPerformed
        // TODO add your handling code here:
        if(cmb_init_dataType.getItemCount()>0)
        {
            if(cmb_init_dataType.getSelectedItem().equals("flag"))
            {
                panel_layout_initialization.remove(txt_init_value);
                panel_layout_initialization.add(cmb_init_flag);
                cmb_init_flag.removeAllItems();
                cmb_init_flag.addItem("true");
                cmb_init_flag.addItem("false");
            }else
            {
                panel_layout_initialization.remove(cmb_init_flag);
                panel_layout_initialization.add(txt_init_value);
            }
        }
    }//GEN-LAST:event_cmb_init_dataTypeActionPerformed

    private void txt_arith_valueMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_txt_arith_valueMouseClicked
        // TODO add your handling code here:
        np.getVariableList(getAllNumericInitializations(),txt_arith_value.getText());
        //parameters: initializations[],previous input
        np.setVisible(true);
    }//GEN-LAST:event_txt_arith_valueMouseClicked

    private void txt_arith_valueFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txt_arith_valueFocusGained
        // TODO add your handling code here:
        txt_arith_value.setText(np.getPseudoCodeEquivalent());//gets value user inputted from the numpad
    }//GEN-LAST:event_txt_arith_valueFocusGained

    private void cmb_set_variableListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmb_set_variableListActionPerformed
        // TODO add your handling code here:
        panel_layout_set_header.remove(panel_layout_set_detail_str);
        panel_layout_set_header.remove(panel_layout_set_detail_num);
        panel_layout_set_header.remove(panel_layout_set_detail_flag);
        panel_layout_set_header.remove(panel_layout_set_detail_char);
        
        panel_layout_set_detail_str.setVisible(false);
        panel_layout_set_detail_num.setVisible(false);
        panel_layout_set_detail_flag.setVisible(false);
        panel_layout_set_detail_char.setVisible(false);
        
        DUMMY_lbl_set_dataTypeContainer.setText(""+getDataType(""+cmb_set_variableList.getSelectedItem()));
        DUMMY_lbl_set_dataTypeContainer.setVisible(false);
        
        if(getDataType(""+cmb_set_variableList.getSelectedItem()).equals("numeric"))
        {
            panel_layout_set_header.add(panel_layout_set_detail_num,BorderLayout.SOUTH);
            panel_layout_set_detail_num.setVisible(true);
        
            txt_setLayout_value.setText("");
        }else
        if(getDataType(""+cmb_set_variableList.getSelectedItem()).equals("flag"))
        {
            panel_layout_set_header.add(panel_layout_set_detail_flag,BorderLayout.SOUTH);
            panel_layout_set_detail_flag.setVisible(true);
            
            cmb_setLayout_value.removeAllItems();
            
            cmb_setLayout_value.addItem("true");
            cmb_setLayout_value.addItem("false");
        }
        if(getDataType(""+cmb_set_variableList.getSelectedItem()).equals("string"))
        {
            panel_layout_set_header.add(panel_layout_set_detail_str,BorderLayout.SOUTH);
            panel_layout_set_detail_str.setVisible(true);
            btn_setLayout_str_deleteVariable.setVisible(false);
             
            txtA_setLayout_str_Value.setText("");
            txt_set_str_variableList.setText("");
            cmb_set_str_variableList.removeAllItems();
            
            fill_combobox_content(cmb_set_str_variableList,"all");
        }else
        if(getDataType(""+cmb_set_variableList.getSelectedItem()).equals("char"))
        {
            panel_layout_set_header.add(panel_layout_set_detail_char,BorderLayout.SOUTH);
            panel_layout_set_detail_char.setVisible(true);
        
            txt_setLayout_value_char.setText("");
        }    
             
}//GEN-LAST:event_cmb_set_variableListActionPerformed

    private void btn_setLayout_str_clearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_setLayout_str_clearActionPerformed
        // TODO add your handling code here:
        txtA_setLayout_str_Value.setText("");
        txt_set_str_variableList.setText("");
    }//GEN-LAST:event_btn_setLayout_str_clearActionPerformed

    private void btn_setLayout_str_appendActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_setLayout_str_appendActionPerformed
        // TODO add your handling code here:
        String str=""+cmb_set_str_variableList.getSelectedItem();
        String str_2 = " "+txt_set_str_variableList.getText()+"";
        txt_set_str_variableList.setText(str_2.trim()+"+"+str);
        
        if(txt_set_str_variableList.getText().equals(""))
            btn_setLayout_str_deleteVariable.setVisible(false);
        else
            btn_setLayout_str_deleteVariable.setVisible(true);
        
        
    }//GEN-LAST:event_btn_setLayout_str_appendActionPerformed

    private void btn_setLayout_str_deleteVariableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_setLayout_str_deleteVariableActionPerformed
        // TODO add your handling code here:
        txt_set_str_variableList.setText(deleteStringUntil(""+txt_set_str_variableList.getText(), '+'));
        
        if(txt_set_str_variableList.getText().equals(""))
            btn_setLayout_str_deleteVariable.setVisible(false);
        else
            btn_setLayout_str_deleteVariable.setVisible(true);
        
    }//GEN-LAST:event_btn_setLayout_str_deleteVariableActionPerformed

    private void txt_set_str_variableListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txt_set_str_variableListActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txt_set_str_variableListActionPerformed

    private void btn_main_conditonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_main_conditonActionPerformed
        // TODO add your handling code here:
        load_ui_conditionLayout();
        current_mode = "condition";
    }//GEN-LAST:event_btn_main_conditonActionPerformed

    private void cmb_condition_firstElementActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmb_condition_firstElementActionPerformed
        // TODO add your handling code here:
        fill_combobox_content(cmb_condition_secondElement,getDataType(""+cmb_condition_firstElement.getSelectedItem()));
        cmb_condition_secondElement.addItem("custom");
    }//GEN-LAST:event_cmb_condition_firstElementActionPerformed

    private void cmb_condition_secondElementActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmb_condition_secondElementActionPerformed
        // TODO add your handling code here:
        if(cmb_condition_secondElement.getItemCount()>0)
        {
            if(cmb_condition_secondElement.getSelectedItem().equals("custom"))
            {
                txtA_custom_input.setText("");
                panel_layout_condition.add(panel_layout_custom,BorderLayout.CENTER);
                panel_layout_custom.setVisible(true);
            }
            else
            {
                panel_layout_condition.remove(panel_layout_custom);
                panel_layout_custom.setVisible(false);
            }
        }
        panel_layout_condition_container.updateUI();
    }//GEN-LAST:event_cmb_condition_secondElementActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:

    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        conditionTest();
        displayToCanvas();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void btn_insertActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_insertActionPerformed
        // TODO add your handling code here:

    }//GEN-LAST:event_btn_insertActionPerformed

    private void jButton3MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton3MouseEntered
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton3MouseEntered

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton3ActionPerformed

    //=====================CRIT FUNCTIONS===========================//
    public String[] process_user_input() 
    /* Disects the users input 
    ** to be inputted in the binary tree. 
    */      
    {
        //original input-to-tree container 
        String string_buffer[] = new String[13]; 
        Symbol symbol = new Symbol();
        /* 0 -keycode           (primary key, unique identifier of each element)
         * 1 -procedure         (process,loop,io,condition)
         * 2 -pseudo            (codes for dummies)
         * 3 -javacode          (codes for bastards with overinflated egos)
         * 4 -connector         (uhhhh...random data?seriously WTF is this?!)
         * 5 -procedure type    (init,arith,cust,etc. Dependent on procedure[1])
         * 6 -dataType          (data contained)
         * 7 -variable          (data contained)
         * 8 -content           (data contained)
         * 9 -mother            (opening code,for conditions and loop only)
         * 10-father            (closing code,for conditions and loop only)
         * 11-flow              (left or right, for conditions and loop only)
         * 12-ParentName        (mother or father)
         */
        if (current_mode.equals("process"))
        {
            if (cmb_procedure.getSelectedItem().equals("initialization"))
            {
                string_buffer[0] = ""+keyCodeGenerator();
                string_buffer[1] = "process";
                string_buffer[2] = "";
                string_buffer[3] = "";
                string_buffer[4] = "";
                string_buffer[5] = "initialization";
                string_buffer[6] = ""+cmb_init_dataType.getSelectedItem();
                string_buffer[7] = ""+txt_init_variable.getText();
                if(!cmb_init_dataType.getSelectedItem().equals("flag"))
                    string_buffer[8] = ""+txt_init_value.getText();
                else
                    string_buffer[8] = ""+cmb_init_flag.getSelectedItem();
                string_buffer[9] = ""+lbl_motherIndexHolder.getText();
                string_buffer[10] = ""+lbl_motherIndexHolder.getText();
                string_buffer[11] = ""+lbl_flowState.getText();
                string_buffer[12] = "";
            }else
            if (cmb_procedure.getSelectedItem().equals("arithmetic"))
            {
                string_buffer[0] = ""+keyCodeGenerator();
                string_buffer[1] = "process";
                string_buffer[2] = "";
                string_buffer[3] = "";
                string_buffer[4] = "";
                string_buffer[5] = "arithmetic";
                string_buffer[6] = "numeric";
                string_buffer[7] = ""+cmb_arith_variable.getSelectedItem();
                string_buffer[8] = ""+txt_arith_value.getText();
                string_buffer[9] = ""+lbl_motherIndexHolder.getText();
                string_buffer[10] = ""+lbl_motherIndexHolder.getText();
                string_buffer[11] = ""+lbl_flowState.getText();
                string_buffer[12] = "";
            }else
            if (cmb_procedure.getSelectedItem().equals("set"))
            {
                string_buffer[0] = ""+keyCodeGenerator();
                string_buffer[1] = "process";
                string_buffer[2] = "";
                string_buffer[3] = "";
                string_buffer[4] = "";
                string_buffer[5] = "set";
                string_buffer[6] = ""+DUMMY_lbl_set_dataTypeContainer.getText();
                string_buffer[7] = ""+cmb_set_variableList.getSelectedItem();
                
                if((DUMMY_lbl_set_dataTypeContainer.getText()).equals("numeric"))
                    string_buffer[8] = ""+txt_setLayout_value.getText();
                else
                if((DUMMY_lbl_set_dataTypeContainer.getText()).equals("string"))
                    string_buffer[8] = ""+txtA_setLayout_str_Value.getText()
                                         +""+txt_set_str_variableList.getText();
                else
                if((DUMMY_lbl_set_dataTypeContainer.getText()).equals("flag"))
                    string_buffer[8] = ""+cmb_setLayout_value.getSelectedItem();
                else
                if((DUMMY_lbl_set_dataTypeContainer.getText()).equals("char"))
                    string_buffer[8] = ""+txt_setLayout_value_char.getText();
                
                string_buffer[9] = ""+lbl_motherIndexHolder.getText();
                string_buffer[10] = ""+lbl_motherIndexHolder.getText();
                string_buffer[11] = ""+lbl_flowState.getText();
                string_buffer[12] = "";
            }else
            if (cmb_procedure.getSelectedItem().equals("set"))
            {
                string_buffer[0] = ""+keyCodeGenerator();
                string_buffer[1] = "process";
                string_buffer[2] = "";
                string_buffer[3] = "";
                string_buffer[4] = "";
                string_buffer[5] = "custom";
                string_buffer[6] = "";
                string_buffer[7] = "";
                string_buffer[8] = ""+txtA_custom_input.getText();
                string_buffer[9] = ""+lbl_motherIndexHolder.getText();
                string_buffer[10] = ""+lbl_motherIndexHolder.getText();
                string_buffer[11] = ""+lbl_flowState.getText();
                string_buffer[12] = "";
                
            }
        }
        if (current_mode.equals("condition"))
        {
                String string_buffer_t[] = new String[13];
                string_buffer_t[0] = ""+keyCodeGenerator();
                string_buffer_t[1] = "condition";
                string_buffer_t[2] = "";
                string_buffer_t[3] = "";
                string_buffer_t[4] = "";
                string_buffer_t[5] = "";
                string_buffer_t[6] = "";
                string_buffer_t[7] = ""+cmb_condition_firstElement.getSelectedItem();
                string_buffer_t[8] = cmb_condition_logicalOperator.getSelectedItem()
                               +""+cmb_condition_secondElement.getSelectedItem();
                string_buffer_t[9] = "mother";
                string_buffer_t[10] = "mother";
                string_buffer_t[11] = ""+lbl_flowState.getText();
                string_buffer_t[12] = "mother";
                
               if(lbl_motherIndexHolder.getText().equals(""))
                    linkList.add(string_buffer_t);
               else
                    linkList.add(getIndexOf(lbl_motherIndexHolder.getText())-1,string_buffer_t);

       
                string_buffer[0] = ""+string_buffer_t[0];
                string_buffer[1] = "condition";
                string_buffer[2] = "";
                string_buffer[3] = "";
                string_buffer[4] = "";
                string_buffer[5] = "";
                string_buffer[6] = "";
                string_buffer[7] = "";
                string_buffer[8] ="C";
                string_buffer[9] = ""+string_buffer_t[0];
                string_buffer[10] = "";
                string_buffer[11] = ""+lbl_flowState.getText();
                string_buffer[12] = "father";
                
        }
        
        lbl_status.setText("<html>"
                          +"STATUS:"
                          +"[0]keycode:"       +string_buffer[0]         
                          +"[1]procedure:"     +string_buffer[1]        
                          +"[2]pseudo:"        +string_buffer[2]    
                          +"[3]javacode:"      +string_buffer[3]          
                          +"[4]connector:"     +string_buffer[4]
                          +"<br/>"
                          +"[5]procedure type:"+string_buffer[5]  
                          +"[6]dataType:"      +string_buffer[6]
                          +"[7]variable:"      +string_buffer[7]  
                          +"[8]content:"       +string_buffer[8]   
                          +"[9]mother:"        +string_buffer[9]   
                          +"[10]father:"        +string_buffer[10] 
                          +"[11]flow:"          +string_buffer[11]
                          +"</html>");

        return string_buffer;
    }
    public void addObjectToLinkedList()//adds data to the tree
    {
       if(lbl_motherIndexHolder.getText().equals(""))
            linkList.add(process_user_input());
       else
       {
            linkList.add(getIndexOf(lbl_motherIndexHolder.getText()),process_user_input());
       }
    }
    public void conditionTest()
    {
 
        /* 0 -keycode           (primary key, unique identifier of each element)
         * 1 -procedure         (process,loop,io,condition)
         * 2 -pseudo            (codes for dummies)
         * 3 -javacode          (codes for bastards with overinflated egos)
         * 4 -connection         (uhhhh...random data?seriously WTF is this?!)
         * 5 -procedure type    (init,arith,cust,etc. Dependent on procedure[1])
         * 6 -dataType          (data contained)
         * 7 -variable          (data contained)
         * 8 -content           (data contained)
         * 9 -mother            (opening code,for conditions and loop only)
         * 10-father            (closing code,for conditions and loop only)
         * 11-flow              (left or right, for conditions and loop only)
         * 12-parentIdentifier  (mother or father)
         */
       String px1[] = new String[13];
       px1[0]="px1"; //keycode      
       px1[1]="process"; //procedure
       px1[4]="px0";
       px1[8]="px1"; //content
       px1[9]="";//mother
       px1[10]="";//father
       px1[11]="normal";//flow
       px1[12]="normal";//flow
       linkList.add(px1);
       
       String px0[] = new String[13];
       px0[0]="px0"; //keycode      
       px0[1]="process"; //procedure   
       px1[4]="m1";
       px0[8]="px0"; //content
       px0[9]="";//mother
       px0[10]="";//father
       px0[11]="normal";//flow
       linkList.add(px0);
       
       String m1[] = new String[13];
       m1[0]="m1"; //keycode      
       m1[1]="condition"; //procedure    
       m1[8]="m1"; //content
       m1[9]="mother";//mother
       m1[10]="mother";//father
       m1[11]="normal";//flow
       m1[12] = "mother";//ismother
       linkList.add(m1);
       
       String m2t[] = new String[13];
       m2t[0]="m2"; //keycode      
       m2t[1]="condition"; //procedure    
       m2t[8]="m2"; //content
       m2t[9]="m1";//mother
       m2t[10]="";//father
       m2t[11]="true";//flow
       m2t[12] = "mother";//ismother
       linkList.add(m2t);
       
       String m3t[] = new String[13];
       m3t[0]="m3"; //keycode      
       m3t[1]="condition"; //procedure    
       m3t[8]="m3"; //content
       m3t[9]="m2";//mother
       m3t[10]="";//father
       m3t[11]="true";//flow
       m3t[12] = "mother";//ismother
       linkList.add(m3t);
       
       String pt9[] = new String[13];
       pt9[0]="pf9"; //keycode      
       pt9[1]="process"; //procedure    
       pt9[8]="pt9"; //content
       pt9[9]="m3";//mother
       pt9[10]="m3";//father
       pt9[11]="true";//flow
       linkList.add(pt9);
       
       String pf8[] = new String[13];
       pf8[0]="pf8"; //keycode      
       pf8[1]="process"; //procedure    
       pf8[8]="pf8"; //content
       pf8[9]="m3";//mother
       pf8[10]="m3";//father
       pf8[11]="false";//flow
       linkList.add(pf8);
       
       String pf11[] = new String[13];
       pf11[0]="pf11"; //keycode      
       pf11[1]="process"; //procedure    
       pf11[8]="pf11"; //content
       pf11[9]="m3";//mother
       pf11[10]="m3";//father
       pf11[11]="false";//flow
       linkList.add(pf11);
       
       
       String m3c[] = new String[13];
       m3c[0]="m3"; //keycode      
       m3c[1]="condition"; //procedure    
       m3c[8]="m3"; //content
       m3c[9]="m3";//mother
       m3c[10]="m2";//father
       m3c[11]="close";//flow
       m3c[12]="father";//ismother
       linkList.add(m3c);
       
       String pf7[] = new String[13];
       pf7[0]="pf7"; //keycode      
       pf7[1]="process"; //procedure    
       pf7[8]="pf7"; //content
       pf7[9]="m2";//mother
       pf7[10]="";//father
       pf7[11]="false";//flow
       linkList.add(pf7);
       
       String m4f[] = new String[13];
       m4f[0]="m4"; //keycode      
       m4f[1]="condition"; //procedure    
       m4f[8]="m4"; //content
       m4f[9]="m2";//mother
       m4f[10]="";//father
       m4f[11]="false";//flow
       m4f[12] = "mother";//ismother
       linkList.add(m4f);
       
       String pt5[] = new String[13];
       pt5[0]="pt5"; //keycode      
       pt5[1]="process"; //procedure    
       pt5[8]="pt5"; //content
       pt5[9]="m4";//mother
       pt5[10]="m4";//father
       pt5[11]="true";//flow
       linkList.add(pt5);
       
       String pf6[] = new String[13];
       pf6[0]="pf6"; //keycode      
       pf6[1]="process"; //procedure    
       pf6[8]="pf6"; //content
       pf6[9]="m4";//mother
       pf6[10]="m4";//father
       pf6[11]="false";//flow
       linkList.add(pf6);
       
       String m4c[] = new String[13];
       m4c[0]="m4"; //keycode      
       m4c[1]="condition"; //procedure    
       m4c[8]="m4"; //content
       m4c[9]="m4";//mother
       m4c[10]="m2";//father
       m4c[11]="close";//flow
       m4c[12] = "father";//ismother
       linkList.add(m4c);
       
       String m2c[] = new String[13];
       m2c[0]="m2"; //keycode      
       m2c[1]="condition"; //procedure    
       m2c[8]="m2"; //content
       m2c[9]="m2";//mother
       m2c[10]="m1";//father
       m2c[11]="close";//flow
       m2c[12] ="father";//ismother
       linkList.add(m2c);
       
       String pf1[] = new String[13];
       pf1[0]="pf1"; //keycode      
       pf1[1]="process"; //procedure    
       pf1[8]="pf1"; //content
       pf1[9]="m1";//mother
       pf1[10]="m1";//father
       pf1[11]="false";//flow
       linkList.add(pf1);
       
       String pf2[] = new String[13];
       pf2[0]="pf2"; //keycode      
       pf2[1]="process"; //procedure    
       pf2[8]="pf2"; //content
       pf2[9]="m1";//mother
       pf2[10]="m1";//father
       pf2[11]="false";//flow
       linkList.add(pf2);
       
       String pf3[] = new String[13];
       pf3[0]="pf3"; //keycode      
       pf3[1]="process"; //procedure    
       pf3[8]="pf3"; //content
       pf3[9]="m1";//mother
       pf3[10]="m1";//father
       pf3[11]="false";//flow
       linkList.add(pf3);
       
       String m1c[] = new String[13];
       m1c[0]="m1"; //keycode      
       m1c[1]="condition"; //procedure    
       m1c[8]="m1"; //content
       m1c[9]="m1";//mother
       m1c[10]="father";//father
       m1c[11]="close";//flow
       m1c[12] ="father";//ismother
       linkList.add(m1c);
       
       
    }
    public void displayToCanvas()//GERALD
    {
        int Y_gapPerElement = 20;
        int X_gapPerElement = 50;
        String str[] = new String[13];
        String str_previous[] = new String[13];
        int father_YGap = 0;
        jTextArea1.setText("");

        canvas.setVisible(true);
        canvas.setBackground(new Color(204, 255, 204));
        canvas.setSize(500,500);
        canvas.setPreferredSize(canvas.getSize());
        canvas.setLayout(null);
        canvas.removeAll();
        canvas.clearLines();
        
        canvas.add(btn_teminal_start);
        btn_teminal_start.setSize(72,24);
        btn_teminal_start.setLocation(alignCenter(canvas,btn_teminal_start),0);
        
        int heightObserver = btn_teminal_start.getHeight();
        for(int i=0;i<linkList.size();i++)
        {
            int x_axis = 0;
            int y_axis = 0;
            
            str = (String[])linkList.get(i);
            
            //button settings
            btn_symbol[i].setText(""+str[8]);
            btn_symbol[i].setSize(84,30);//mardie
            //add elements to canvas
            canvas.add(btn_symbol[i]);
            //panel size settings---
            heightObserver += father_YGap + Y_gapPerElement + btn_symbol[i].getHeight();
            //canvas.setSize(500,heightObserver);
            canvas.setSize(500,5000);
            canvas.setPreferredSize(canvas.getSize());
            //locations-----
            if(i==0)
            {
                x_axis = (int)getLocationNextOf(btn_teminal_start,btn_symbol[i],Y_gapPerElement).getX();
                y_axis = (int)getLocationNextOf(btn_teminal_start,btn_symbol[i],Y_gapPerElement).getY();
            }else
            {
                if(str[11].equals("normal"))
                {
                    x_axis = (int)getLocationNextOf(btn_symbol[i-1],btn_symbol[i],Y_gapPerElement).getX();
                    y_axis = (int)getLocationNextOf(btn_symbol[i-1],btn_symbol[i],Y_gapPerElement).getY();
                }
//                if(str[12].equals("mother"))
//                {
//                    addTFRoutes(i,new Point(x_axis,y_axis),btn_symbol[i],X_gapPerElement);
//                }
                if(str[12].equals("father"))
                {
                    x_axis = (int)getLocationNextOf(btn_symbol[getMotherIndexOf(i)],btn_symbol[i],father_YGap).getX();
                    y_axis = (int)setFatherLocation(str[9],i).getY()+Y_gapPerElement;
                }
                if(str[11].equals("true"))
                {
                    if(getTFReference(str[9],i,"true")==0)
                    {
                        x_axis = (int)getLocationNextOf(btn_trueRoute[getMotherIndex(str[9])],btn_symbol[i],Y_gapPerElement).getX();
                        y_axis = (int)getLocationNextOf(btn_trueRoute[getMotherIndex(str[9])],btn_symbol[i],Y_gapPerElement).getY();
                    }else
                    {
                        x_axis = (int)getLocationNextOf(btn_symbol[getTFReference(str[9],i,"true")],btn_symbol[i],Y_gapPerElement).getX();
                        y_axis = (int)getLocationNextOf(btn_symbol[getTFReference(str[9],i,"true")],btn_symbol[i],Y_gapPerElement).getY();
                    }
                }
                
                if(str[11].equals("false")) 
                {
                    if(getTFReference(str[9],i,"false")==0)
                    {
                        x_axis = (int)getLocationNextOf(btn_falseRoute[getMotherIndex(str[9])],btn_symbol[i],Y_gapPerElement).getX();
                        y_axis = (int)getLocationNextOf(btn_falseRoute[getMotherIndex(str[9])],btn_symbol[i],Y_gapPerElement).getY();
                    }else
                    {
                        x_axis = (int)getLocationNextOf(btn_symbol[getTFReference(str[9],i,"false")],btn_symbol[i],Y_gapPerElement).getX();
                        y_axis = (int)getLocationNextOf(btn_symbol[getTFReference(str[9],i,"false")],btn_symbol[i],Y_gapPerElement).getY();
                    }
                }
                if(str[12].equals("mother")) // GERALD X1
                {
                    addTFRoutes(i,new Point(x_axis,y_axis),btn_symbol[i],X_gapPerElement);
                }                           // X1
            }
            btn_symbol[i].setLocation(x_axis,y_axis);
            //lines---------
            if(str[11].equals("normal"))
            {
                if(i==0)
                    addVerticalLineInBetween(btn_teminal_start,btn_symbol[i]);
                else
                {
                    if(!str[12].equals("father"))
                        addVerticalLineInBetween(btn_symbol[i-1],btn_symbol[i]);
                }
            }
            if(str[12].equals("mother"))
            {
                addHorizontalLineInBetween(btn_trueRoute[i],btn_symbol[i]);
                addHorizontalLineInBetween(btn_falseRoute[i],btn_symbol[i]);
            }
            if(str[12].equals("father"))
            {
                addFatherLine(btn_symbol[i],btn_trueRoute[getMotherIndexOf(i)]);
                addFatherLine(btn_symbol[i],btn_falseRoute[getMotherIndexOf(i)]);
            }
            jTextArea1.append(""
                              +"STATUS-----------------------------------"
                             +"\n" +"[i]index:"       +i  
                             +"\n" +"[0]keycode:"       +str[0]         
                             +"\n" +"[1]procedure:"     +str[1]        
                             +"\n" +"[2]pseudo:"        +str[2]    
                             +"\n" +"[3]javacode:"      +str[3]          
                             +"\n" +"[4]connector:"     +str[4]
                             +"\n" +"[5]procedure type:"+str[5]  
                             +"\n" +"[6]dataType:"      +str[6]
                             +"\n" +"[7]variable:"      +str[7]  
                             +"\n" +"[8]content:"       +str[8]   
                             +"\n" +"[9]mother:"        +str[9]   
                             +"\n" +"[10]father:"        +str[10] 
                             +"\n" +"[11]flow:"          +str[11]
                             +"\n" +"[12]parent:"          +str[12]
                             +"\n" +"");
            }
        canvas.repaint();
    }
    public Point setFatherLocation(String motherKeyCode, int fatherIndex)
    {
        String str[] = new String[13];
        int trueCount = 0;
        int falseCount = 0;
        int trueIndex = 0;
        int falseIndex = 0;
        boolean trueFlag = false;
        boolean falseFlag = false;
        
        int count = 0;
        int index = 0;
        
        int x = 0;
        int y = 0;
        Point location = new Point(0,0);
        for(int i=fatherIndex;i>-1;i--)
        {
            str = (String[])linkList.get(i);
            if(str[12].equals("mother"))
            {
                if(str[9].equals(motherKeyCode))
                {
                    break;//control
                }
            }
            if(str[9].equals(motherKeyCode))
            {
                if(str[11].equals("true"))
                {
                    trueCount++;
                    if(trueFlag==false)
                        trueIndex = i;
                    trueFlag = true;
                }
                if(str[11].equals("false"))
                {
                    falseCount++;
                    if(falseFlag==false)
                        falseIndex = i;
                    falseFlag = true;
                }
            }
        }
        if(trueCount>falseCount)
        {
            count = trueCount;
            index = trueIndex;
        }
        else
        {
            count = falseCount;
            index = falseIndex;
        }
        if(count==0)
        {
            y = btn_symbol[getMotherIndex(motherKeyCode)].getY()+btn_symbol[getMotherIndex(motherKeyCode)].getHeight();
            x = btn_symbol[getMotherIndex(motherKeyCode)].getX();
        }else
        {
            y = btn_symbol[index].getY()+btn_symbol[index].getHeight();
            x = btn_symbol[index].getX();
        }
        location = new Point(x,y);
        return location;
    }
    public int getTFReference(String motherKeyCode, int sourceIndex, String route)
    {
        
        int index = 0;
        String str[] = new String[13];
        for(int i=sourceIndex-1;i>-1;i--)
        {
            str = (String[])linkList.get(i);
            if(str[12].equals("mother"))
            {
                if(str[9].equals(motherKeyCode))
                {
                    break;//control
                }
            }
            if(str[11].equals(route))
            {
                if(str[9].equals(motherKeyCode))
                {
                    index = i;
                    break;
                }
            }
        }
        return index;
    }
    public String getMotherCode(int index)
    {
        String str = "";
        String con[] = new String[13];
        con = (String[])linkList.get(index);
        str = con[0];
        return str;
    }
    public int getIndexOf(String keycode)
    {
        int index = 0;
        String str[] = new String[13];
        for(int i=0;i<linkList.size();i++)
        {
            str = (String[])linkList.get(i);
            if(str[0].equals(keycode))
                index = i;
        }
        return index;
    }
    public int getMotherIndex(String keycode)
    {
        int index=0;
        String str[] = new String[13];
        for(int i=0;i<linkList.size();i++)
        {
            str = (String[])linkList.get(i);
            if(str[12].equals("mother"))
            {
                if(str[0].equals(keycode))
                    index = i;
            }
        }
        return index;
    }
    public int getMotherIndexOf(int sourceIndex)
    {
        int index = 0;
        String str[] = new String[13];
        String source[] = new String[13];
        source = (String[])linkList.get(sourceIndex);
        for(int i=sourceIndex;i>-1;i--)
        {
            str = (String[])linkList.get(i);
            if(source[0].equals(str[0]))
            {
                index=i;
            }
        }
        return index;
    }
    public void addFatherLine(JButton father, JButton target)
    {
        /*  ______
         * |      |<-target
         * |______|
         *    |       
         *    |<-vertical line                   
         *    |                  ________
         *    |___horizontal____|        | <-father
         *                      |________|
         */
        int v_x1=0,v_y1=0,v_x2=0,v_y2=0;//vertical
        int h_x1=0,h_y1=0,h_x2=0,h_y2=0;//horizontal
        //vertical
        v_x1 = (int)getBottomCenterCoordinates(target).getX();
        v_y1 = (int)getBottomCenterCoordinates(target).getY();
        v_x2 = v_x1;
        v_y2 = (int)getLeftMiddleCoordinates(father).getY();
        //horizontal
        h_x1 = (int)getLeftMiddleCoordinates(father).getX();
        h_y1 = v_y2;
        h_x2 = v_x2;
        h_y2 = v_y2;
        
        canvas.addLine(v_x1,v_y1,v_x2,v_y2);//vertical
        canvas.addLine(h_x1,h_y1,h_x2,h_y2);//horizontal
    }

    public void addTFRoutes(int index,Point mother,JButton btn_mother,int gap)
    {
        /*  _____       ______       _____
         * |true |     |      |     |false|    
         * |route|-gap-|mother|-gap-|route|
         * |_____|     |______|     |_____|
         * 
         * index - index of mother in the list link
         * Point mother - location of mother in the canvas
         * btn_mother - button container of mother
         * gap - gap set in between flowchart elements
         */
        int x=0,y=0;
        //true
        x = (int)mother.getX()-(gap+btn_trueRoute[index].getWidth());
        y = ((int)mother.getY()+(btn_mother.getHeight()/2))-(btn_trueRoute[index].getHeight()/2);
        canvas.add(btn_trueRoute[index]);
        btn_trueRoute[index].setLocation(x,y);
        
        //false
        x = ((int)mother.getX()+btn_mother.getWidth())+gap;
        y = ((int)mother.getY()+(btn_mother.getHeight()/2))-(btn_falseRoute[index].getHeight()/2);
        canvas.add(btn_falseRoute[index]);
        btn_falseRoute[index].setLocation(x,y);
    }

    public void addHorizontalLineInBetween(JButton parent, JButton child)
    {
        /*  a = x1,y1       b = x2,y2
         *  _______          _______
         * |       |        |       |
         * |       a--------b       |
         * |_______|        |_______|
         *   child           parent
         */ 
        int x1=0,y1=0,
            x2=0,y2=0;
        x1 = (int)getLeftMiddleCoordinates(parent).getX();
        y1 = (int)getLeftMiddleCoordinates(parent).getY();
        x2 = (int)getRightMiddleCoordinates(child).getX();
        y2 = (int)getRightMiddleCoordinates(child).getY();
        canvas.addLine(x1,y1,x2,y2);
    }
    public void addVerticalLineInBetween(JButton parent,JButton child)
    {
        /*  
         *  _______
         * |       |  ->parent
         * |___a___|  a - x1,y1
         *     |
         *  ___b___   
         * |       |  b = x2,y2
         * |_______|  ->child
         * 
         */
        int x1=0,y1=0,
            x2=0,y2=0;
        x1 = (int)getBottomCenterCoordinates(parent).getX();
        y1 = (int)getBottomCenterCoordinates(parent).getY();
        x2 = (int)getTopCenterCoordinates(child).getX();
        y2 = (int)getTopCenterCoordinates(child).getY();
        canvas.addLine(x1,y1,x2,y2);
    }
    public Point getLocationNextOf(JButton parent,JButton child,int gap)
    {
        /* x:return point, x is autocentered based on the width of parent and child.
         *  _______
         * |_______| ->parent
         *     |
         *    gap
         *     |
         * x-------- ->position of child to be set
         * |
         */
        int x=0,y=0;
        x = parent.getX()+((parent.getWidth()-child.getWidth())/2);
        y = parent.getY()+parent.getHeight()+gap;
        return new Point(x,y);
    }
    public Point getLeftMiddleCoordinates(JButton button)
    {
        /* x: return point
         *  ________
         * |        |
         * x button |
         * |________|
         */
        int x=0,y=0;
        x = button.getX();
        y = button.getY()+(button.getHeight()/2);
        return new Point(x,y);
    }
    public Point getRightMiddleCoordinates(JButton button)
    {
        /* x:return point
         *  ________
         * |        |
         * | button x
         * |________|
         */
        int x=0,y=0;
        x = button.getX()+button.getWidth();
        y = button.getY()+(button.getHeight()/2);
        return new Point(x,y);
    }
    public Point getBottomCenterCoordinates(JButton button)
    {
        /* x:return point
         *  _______
         * |       | <-button
         * |___x___|
         */
        int x=0,y=0;
        x = button.getX()+button.getWidth()/2;
        y = button.getY()+button.getHeight();
        return new Point(x,y);
    }
    public Point getTopCenterCoordinates(JButton button)
    {
        /* x:return point
         *  ___x___
         * |       | <-button
         * |_______|
         */
        int x=0,y=0;
        x = button.getX()+button.getWidth()/2;
        y = button.getY();
        return new Point(x,y);
    }

    public int alignCenter(JPanel panel, JButton button)
    {        
        int x = 0;
        x = (panel.getWidth()/2)-(button.getWidth()/2);
        return x;
    }
    public void initializeFlowchartElements()
    {
        for(int i=0;i<1000;i++)
        {
            btn_symbol[i] = new JButton();
            btn_arrow[i][0] = new JButton();
            btn_trueRoute[i] = new JButton();
            btn_falseRoute[i] = new JButton();
            
            btn_arrow_vertical_dummy[i][0] = new JButton();
            btn_arrow_horizontal_T[i][0] = new JButton();
            btn_arrow_horizontal_F[i][0] = new JButton(); 
            btn_arrow_horizontal_TC[i][0] = new JButton();
            btn_arrow_horizontal_FC[i][0] = new JButton(); 
            
            btn_arrow_vertical_dummy[i][0].setBorderPainted(false);
            btn_arrow_vertical_dummy[i][0].setContentAreaFilled(false);
            btn_arrow_vertical_dummy[i][0].setMargin(new Insets(0,0,0,0));
            btn_arrow_vertical_dummy[i][0].setBorder(null); 
            
            btn_arrow_horizontal_T[i][0].setBorderPainted(false);
            btn_arrow_horizontal_T[i][0].setContentAreaFilled(false);
            btn_arrow_horizontal_T[i][0].setMargin(new Insets(0,0,0,0));
            btn_arrow_horizontal_T[i][0].setBorder(null); 
            
            btn_arrow_horizontal_F[i][0].setBorderPainted(false);
            btn_arrow_horizontal_F[i][0].setContentAreaFilled(false);
            btn_arrow_horizontal_F[i][0].setMargin(new Insets(0,0,0,0));
            btn_arrow_horizontal_F[i][0].setBorder(null); 
            
            btn_arrow_horizontal_TC[i][0].setBorderPainted(false);
            btn_arrow_horizontal_TC[i][0].setContentAreaFilled(false);
            btn_arrow_horizontal_TC[i][0].setMargin(new Insets(0,0,0,0));
            btn_arrow_horizontal_TC[i][0].setBorder(null); 
            
            btn_arrow_horizontal_FC[i][0].setBorderPainted(false);
            btn_arrow_horizontal_FC[i][0].setContentAreaFilled(false);
            btn_arrow_horizontal_FC[i][0].setMargin(new Insets(0,0,0,0));
            btn_arrow_horizontal_FC[i][0].setBorder(null); 
            
            btn_arrow[i][0].setBorderPainted(false);
            btn_arrow[i][0].setContentAreaFilled(false);
            btn_arrow[i][0].setMargin(new Insets(0,0,0,0));
            btn_arrow[i][0].setBorder(null);
                    
            btn_symbol[i] = new JButton();
            btn_arrow[i][1] = new JButton();
            
            arrow_head[i] = new JButton();  
            arrow_head[i].setBorderPainted(false);
            arrow_head[i].setContentAreaFilled(false);
            arrow_head[i].setMargin(new Insets(0,0,0,0));
            arrow_head[i].setBorder(null);
            
            btn_symbol[i].addActionListener(this);
            btn_symbol[i].addMouseListener(this);
            btn_arrow[i][0].addActionListener(this);
            btn_arrow_horizontal_T[i][0].addActionListener(this);
            btn_arrow_vertical_dummy[i][0].addActionListener(this);
            btn_trueRoute[i].addActionListener(this);
            btn_falseRoute[i].addActionListener(this);
            
            btn_symbol[i].setVisible(true);
            
            btn_trueRoute[i].setSize(50,23);
            btn_falseRoute[i].setSize(50,23);
            
            btn_trueRoute[i].setText("true");
            btn_falseRoute[i].setText("false");   
            
            btn_falseRoute[i].setMargin(new Insets(0,0,0,0));
            btn_trueRoute[i].setMargin(new Insets(0,0,0,0));

            
        }
    }

    public void fill_combobox_content(JComboBox targetComboBox,String type)
    /*****************************************************************************************
    ** populates the combo box in the parameter(targetComboBox) with data from the binary tree
    *****************************************************************************************/              
    {
        targetComboBox.removeAllItems();//cleans combobox
        String string_buffer[] = new String[5]; 
        // 0-keycode 1-procedure 2-pseudo; 3-javacode 4-connector 5-type 6-dataType 7-variable 8-content
        for(int i =0;i<linkList.size();i++)
        {
            string_buffer = (String[]) linkList.get(i);
            if (string_buffer[5].equals("initialization"))//ensures that the data extracted is an "Initialization"
            {
                if(string_buffer[6].equals(type))
                    targetComboBox.addItem(string_buffer[7]);
                else
                if(type.equals("all"))
                    targetComboBox.addItem(string_buffer[7]);
            }
        }
       
    }
    public String[] getAllNumericInitializations()//returns all initializations classified as numeric
    {
        String variables[] = new String[100];
        int i = 0;
        String string_buffer[] = new String[9];
        // 0-keycode 1-procedure 2-pseudo; 3-javacode 4-connector 5-type 6-dataType 7-variable 8-content
        for(int x=0;x<linkList.size();x++)
        {
            string_buffer = (String[])linkList.get(x);
            if (string_buffer[5].equals("initialization"))
            {
                if(string_buffer[6].equals("numeric"))
                {
                    variables[i] = string_buffer[7];
                    i++;
                }
            }
        }
        return variables;
    }
    public void clearAllTextBoxes()
    {
        txt_arith_value.setText("");
        txt_init_value.setText("");
        txt_init_variable.setText("");
    }
    public String getDataType(String input)
    {
        String str = "";
        String string_buffer[] = new String[9];
        // 0-keycode 1-procedure 2-pseudo; 3-javacode 4-connector 5-type 6-dataType 7-variable 8-content
        for(int i=0;i<linkList.size();i++)
        {
            string_buffer = (String[]) linkList.get(i);
            if (string_buffer[5].equals("initialization"))
            {
                if(string_buffer[7].equals(input))
                {
                    str = string_buffer[6];
                }
            }
        }
        return str;
    }
    public String deleteStringUntil(String str_i, char control)//string to be worked on, control string
    {
        for(int i=str_i.length()-1;i>-1;i--)
        {
            if(str_i.charAt(i)!=control)
            {       
                str_i = singleBackspace(str_i);
            }else
            {
                str_i = singleBackspace(str_i);
                break;
            }
        } 
        return str_i;
    }
    public String singleBackspace(String str_i)
    {
        String str_r = "";
        for(int i=0;i<str_i.length()-1;i++)
        {
            str_r += str_i.charAt(i);//transfer to temp except last
        }
        return str_r;
    }
    public String keyCodeGenerator()
    {
        String str = "Flow_"+key_tracker;
        key_tracker++;
        return str;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new JCCFlux().setVisible(true);
            }
        });
    }
    //*********GERALD************//

    private javax.swing.JButton[] arrow_head = new JButton[1000]; //object GERALD X0003    
    //***************************//
    
    LinkedList linkList=new LinkedList();
    private JCCFunctions JCCF = new JCCFunctions();
    private Numpad np = new Numpad();
    private String current_mode = "";
    
    private String key_code = "";
    private int key_tracker =0;
    private Symbol symbol = new Symbol();

    private javax.swing.JButton[] btn_symbol = new JButton[1000]; //00 button, 01keycode
    private javax.swing.JButton[][] btn_arrow = new JButton[1000][2]; //00 button, 01 keycode
    private javax.swing.JButton[][] btn_arrow_horizontal_T = new JButton[1000][2]; //00 button, 01 keycode
    private javax.swing.JButton[][] btn_arrow_horizontal_F = new JButton[1000][2]; //00 button, 01 keycode
    private javax.swing.JButton[][] btn_arrow_vertical_dummy = new JButton[1000][2]; //00 button, 01 keycode 
    private javax.swing.JButton[][] btn_arrow_horizontal_TC = new JButton[1000][2]; //00 button, 01 keycode
    private javax.swing.JButton[][] btn_arrow_horizontal_FC = new JButton[1000][2]; //00 button, 01 keycode
    
    private javax.swing.JButton[] btn_trueRoute = new JButton[1000]; //00 button, 01keycode
    private javax.swing.JButton[] btn_falseRoute = new JButton[1000]; //00 button, 01 keycode
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel DUMMY_lbl_set_dataTypeContainer;
    private javax.swing.JButton btn_add;
    private javax.swing.JButton btn_delete;
    private javax.swing.JButton btn_edit;
    private javax.swing.JButton btn_insert;
    private javax.swing.JButton btn_main_conditon;
    private javax.swing.JButton btn_main_io;
    private javax.swing.JButton btn_main_loops;
    private javax.swing.JButton btn_main_process;
    private javax.swing.JButton btn_setLayout_str_append;
    private javax.swing.JButton btn_setLayout_str_clear;
    private javax.swing.JButton btn_setLayout_str_deleteVariable;
    private javax.swing.JButton btn_teminal_start;
    private javax.swing.JComboBox cmb_arith_variable;
    private javax.swing.JComboBox cmb_condition_firstElement;
    private javax.swing.JComboBox cmb_condition_logicalOperator;
    private javax.swing.JComboBox cmb_condition_secondElement;
    private javax.swing.JComboBox cmb_init_dataType;
    private javax.swing.JComboBox cmb_init_flag;
    private javax.swing.JComboBox cmb_procedure;
    private javax.swing.JComboBox cmb_setLayout_value;
    private javax.swing.JComboBox cmb_set_str_variableList;
    private javax.swing.JComboBox cmb_set_variableList;
    private javax.swing.Box.Filler filler1;
    private javax.swing.JPanel flowchart_panel_container;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextArea jTextArea2;
    private javax.swing.JLabel lbl_flowState;
    private javax.swing.JLabel lbl_motherContainer;
    private javax.swing.JLabel lbl_motherIndexHolder;
    private javax.swing.JLabel lbl_properties;
    private javax.swing.JLabel lbl_properties1;
    private javax.swing.JLabel lbl_status;
    private javax.swing.JPanel panel_addEditDelete;
    private javax.swing.JPanel panel_layout_arithmetic;
    private javax.swing.JPanel panel_layout_condition;
    private javax.swing.JPanel panel_layout_condition_container;
    private javax.swing.JPanel panel_layout_custom;
    private javax.swing.JPanel panel_layout_initialization;
    private javax.swing.JPanel panel_layout_process;
    private javax.swing.JPanel panel_layout_set_detail_char;
    private javax.swing.JPanel panel_layout_set_detail_flag;
    private javax.swing.JPanel panel_layout_set_detail_num;
    private javax.swing.JPanel panel_layout_set_detail_str;
    private javax.swing.JPanel panel_layout_set_header;
    private javax.swing.JPanel panel_layout_set_header_container;
    private javax.swing.JPanel panel_left_mainTools;
    private javax.swing.JPanel panel_mainButtons;
    private javax.swing.JPanel panel_north_toolBar;
    private javax.swing.JPanel panel_processLayout_header;
    private javax.swing.JPanel panel_properties;
    private javax.swing.JPanel panel_properties_container;
    private javax.swing.JPanel panel_south_etc;
    private javax.swing.JScrollPane scrollP_flowchartDisplay;
    private javax.swing.JScrollPane scroll_left_mainTools;
    private javax.swing.JTextArea txtA_custom_input;
    private javax.swing.JTextArea txtA_setLayout_str_Value;
    private javax.swing.JTextField txt_arith_value;
    private javax.swing.JTextField txt_init_value;
    private javax.swing.JTextField txt_init_variable;
    private javax.swing.JTextField txt_setLayout_value;
    private javax.swing.JTextField txt_setLayout_value_char;
    private javax.swing.JTextField txt_set_str_variableList;
    // End of variables declaration//GEN-END:variables
}
